#!/bin/sh

uci -q get system.@imm_init[0] > "/dev/null" || uci -q add system imm_init > "/dev/null"

if ! uci -q get system.@imm_init[0].lang > "/dev/null"; then
	uci -q set luci.main.lang="auto"
	uci -q commit luci

	uci -q set system.@imm_init[0].lang="1"
	uci -q commit system
fi

uci -q set luci.main.socket="/var/run/ubus.sock"
uci -q commit luci

#if ! uci -q get system.@imm_init[0].anon_mount > "/dev/null"; then
#	uci -q set fstab.@global[0].anon_mount="1"
#	uci -q commit fstab

#	uci -q set system.@imm_init[0].anon_mount="1"
#	uci -q commit system
#fi

ln -sf "/sbin/ip" "/usr/bin/ip"

[ ! -e "/bin/bash" ] || sed -i "s|root:x:0:0:root:/root:/bin/ash|root:x:0:0:root:/root:/bin/bash|g" "/etc/passwd"

sed -i "/log-facility/d" "/etc/dnsmasq.conf"
echo "log-facility=/dev/null" >> "/etc/dnsmasq.conf"

rm -rf "/tmp/luci-modulecache"
rm -f "/tmp/luci-indexcache"

exit 0
